<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\User;
use App\Model\Good;
 

class IndexController extends Controller
{
    public function index()
    {
    	$user = User::select(['id','name','pass'])->where('id',1)->get();

    	return view('Home/cart');
    }

    public function detail(Request $request)
    {
        $keyword = $request->input('keyword');

        $map = [];
        if ($keyword) {

          $map[] = ['gname', 'like', '%'.$keyword.'%'];
          
        }

        

        $goods = Good::select(['id','gname','price'])->where($map)->paginate(5);

    	return view('Home/detail',
    		[
    		'good'=>$goods,
            'keyword'=>$keyword,
    		]);
    }


    public function up()
    {
        return view('Home/upfield');
    }
}
